import sys,math,os
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
class ListWidgetDemo(QListWidget):
    def clicked(self,item ):
        QMessageBox.information(self,"Listwidget","选择了:"+item.text())

if __name__ == '__main__':
    app=QApplication(sys.argv)
    listWidget=ListWidgetDemo()
    listWidget.resize(300,150)
    listWidget.addItem("item1")
    listWidget.addItem("item2")
    listWidget.addItem("item3")
    listWidget.addItem("item4")
    listWidget.setWindowTitle("list案例")
    listWidget.itemClicked.connect(listWidget.clicked)

    listWidget.show()
    sys.exit(app.exec_())